//
// Created by 刘禹晨 on 5/19/16.
// Copyright (c) 2016 刘禹晨. All rights reserved.
//

#import "LineView.h"

@interface LineView()

{
    int direction;
}

@end

@implementation LineView

-(id)initWithFrame:(CGRect)frame
        direction:(int)dir{
    
    direction = dir;

    self = [super initWithFrame:frame];
    if(self)
    {
        
    }
    self.backgroundColor = [UIColor clearColor];
    return self;
}


-(void)drawRect:(CGRect)rect {
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGMutablePathRef path = CGPathCreateMutable();

    if(direction == RIGHT){
        CGPathMoveToPoint(path,NULL,0,0);
        CGPathAddLineToPoint(path,NULL,rect.size.width,rect.size.height);
    }else{
        CGPathMoveToPoint(path,NULL,rect.size.width,0);
        CGPathAddLineToPoint(path,NULL,0,rect.size.height);
    }

    CGContextAddPath(context,path);

    CGContextStrokePath(context);
    CGPathRelease(path);
}


@end